<template>
  <confirm-button
    v-bind="attrs"
    @ok="$emit('ok')"
    @cancel="$emit('cancel')"
  >
    <p slot="content">确定要删除吗？</p>
    <template v-if="!icon">删除</template>
  </confirm-button>
</template>

<script>
export default {
  name: 'delete-confirm-button',
  inheritAttrs: false,
  props: {
    // 图标模式，仅显示图标
    icon: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      attrs: {}
    }
  },
  created() {
    let defaults = {
      type: 'danger',
      plain: true
    };
    if (this.icon) {
      defaults.icon = 'el-icon-delete';
      defaults.circle = true;
    }
    this.attrs = {...defaults, ...this.$attrs};
  }
}
</script>